var tempImage = null;
var HISTORY= 'https://www.maksdu.com/app/';

function deleteSpecial(ids) {
	if(confirm('确定要删除板块吗？')) {
		$.ajax({
			url:HISTORY+'type/delete',
			data: {
				typeid:ids
			},
			method:'post',
			success:function(data) {
				if(data) {
					$("#mytable").bootstrapTable('refresh');
				}
			}
		});
	}
}

$(function(){
	$("select[name='category']").empty();
	$("select[name='category']").append("<option value=\"-1\">--请先选择--</option>");
	$.ajax({
		url: HISTORY+'category/all',
		method: 'get',
		success: function(result) {
			var data = result.result.value;
			for(var i=0;i<data.length;i++) {
				$("select[name='category']")
					.append("<option value="+data[i].id+">"+data[i].categoryName+"</option>");
			}
		}
	});
	$("#mytable").bootstrapTable('refresh');
})
/*新增专区*/
function addNewSpecial() {
	$.ajax({
		url:HISTORY+'type/create',
		method: 'post',
		data : {
			typeName: $("input[name='name']").val(),
			categoryid: $("select[name='category']").val(),
			icon: tempImage
		},
		success:function(data) {
			data && getSpecialBlock();
		}
	});
}

var setTemp = function(value) {
	tempImage = value;
}

var reset = function() {
	tempImage = null;
}
